<ix-modal-header
  [requiredRoles]="requiredRoles"
  [title]="'SSH' | translate"
  [loading]="isFormLoading()"
></ix-modal-header>

<mat-card class="card">
  <mat-card-content>
    <form class="ix-form-container" [formGroup]="form" (submit)="onSubmit()">
      <ix-fieldset [title]="'General Options' | translate">
        <ix-input
          formControlName="tcpport"
          type="number"
          [label]="'TCP Port' | translate"
          [tooltip]="tooltips.tcpport | translate"
        ></ix-input>

        <ix-chips
          [formControl]="form.controls.password_login_groups"
          [label]="'Password Login Groups' | translate"
          [autocompleteProvider]="groupProvider"
          [tooltip]="tooltips.password_login_groups | translate"
        ></ix-chips>

        <ix-checkbox
          formControlName="passwordauth"
          [label]="'Allow Password Authentication' | translate"
          [tooltip]="tooltips.passwordauth | translate"
        ></ix-checkbox>

        <ix-checkbox
          formControlName="kerberosauth"
          [label]="'Allow Kerberos Authentication' | translate"
          [tooltip]="tooltips.kerberosauth | translate"
        ></ix-checkbox>

        <ix-checkbox
          formControlName="tcpfwd"
          [label]="'Allow TCP Port Forwarding' | translate"
          [tooltip]="tooltips.tcpfwd | translate"
        ></ix-checkbox>
      </ix-fieldset>

      @if (!isBasicMode) {
        <ix-fieldset>
          <ix-select
            formControlName="bindiface"
            [label]="'Bind Interfaces' | translate"
            [tooltip]="tooltips.bindiface | translate"
            [multiple]="true"
            [options]="bindInterfaces$"
          ></ix-select>

          <ix-checkbox
            formControlName="compression"
            [label]="'Compress Connections' | translate"
            [tooltip]="tooltips.compression | translate"
          ></ix-checkbox>

          <ix-select
            formControlName="sftp_log_level"
            emptyValue=""
            [label]="'SFTP Log Level' | translate"
            [tooltip]="tooltips.sftp_log_level | translate"
            [options]="sftpLogLevels$"
          ></ix-select>

          <ix-select
            formControlName="sftp_log_facility"
            [label]="'SFTP Log Facility' | translate"
            [tooltip]="tooltips.sftp_log_facility | translate"
            [options]="sftpLogFacilities$"
          ></ix-select>

          <ix-select
            formControlName="weak_ciphers"
            [label]="'Weak Ciphers' | translate"
            [tooltip]="tooltips.weak_ciphers | translate"
            [multiple]="true"
            [options]="sshWeakCiphers$"
          ></ix-select>

          <ix-textarea
            formControlName="options"
            [label]="'Auxiliary Parameters' | translate"
            [tooltip]="tooltips.options | translate"
          ></ix-textarea>
        </ix-fieldset>
      }

      <ix-form-actions>
        <button
          *ixRequiresRoles="requiredRoles"
          mat-button
          type="submit"
          color="primary"
          ixTest="save"
          [disabled]="form.invalid || isFormLoading()"
        >
          {{ 'Save' | translate }}
        </button>

        <button mat-button type="button" ixTest="toggle-advanced-options" (click)="onAdvancedSettingsToggled()">
          {{
            isBasicMode
              ? ('Advanced Settings' | translate)
              : ('Basic Settings' | translate)
          }}
        </button>
      </ix-form-actions>
    </form>
  </mat-card-content>
</mat-card>
